import java.util.Arrays;

/**
 * ClassName: O3ArraysUtils
 * Package: PACKAGE_NAME
 * Description:
 *
 * @Author 糕糕
 * @Create 2024-01-29 18:18
 * @Version 1.0
 */
public class O3ArraysUtils {
    public static void main(String[] args) {

        //1.equals 比较两个数组元素是否依次相等
        int[] arr1 = new int[]{1, 2, 3};
        int[] arr2 = new int[]{1, 2, 3};

        System.out.print(Arrays.equals(arr1, arr2) + "\t");//比较里面的元素
        System.out.println(arr1 == arr2);

        //2.toStrings 输出数组元素的信息
        System.out.println(Arrays.toString(arr1));
        System.out.println(Arrays.toString(arr2));


        //fill 将指定值填充到数组中心
        int[] arr3 = new int[5];
        Arrays.fill(arr3, 10);
        System.out.println(Arrays.toString(arr3));

        //sort 使用快速排序算法实现排序
        int[] arr4 = new int[]{5, 89, 12, 45, 65, 21, 5, 7, 3, 9, 14};
        Arrays.sort(arr4);
        System.out.println(Arrays.toString(arr4));

        //binarySearch 二分查找 使用前提:当前数组必须是有序的
        int index = Arrays.binarySearch(arr4, 5);
        System.out.println(index);


    }

}
